/* PLC面板基础样式 */
.plc-panel {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.plc-panel h2 {
  color: #333;
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.plc-panel h3 {
  color: #555;
  margin: 20px 0 15px 0;
}

/* 控制按钮区域 */
.plc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f5f5f5;
  border-radius: 8px;
}

.plc-controls button {
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  background-color: #2196F3;
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.3s;
}

.plc-controls button:hover:not(:disabled) {
  background-color: #1976D2;
}

.plc-controls button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.plc-controls button.connected {
  background-color: #4CAF50;
}

.plc-controls button.connected:hover {
  background-color: #388E3C;
}

/* 错误消息 */
.error-message {
  background-color: #ffebee;
  color: #c62828;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
  border-left: 4px solid #f44336;
}

/* 分组区域 */
.plc-groups {
  margin-bottom: 30px;
}

.group-list-container {
  background-color: #fafafa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

/* 分组统计信息 */
.group-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  color: #666;
  font-size: 14px;
}

.active-group-info {
  background-color: #e3f2fd;
  padding: 4px 8px;
  border-radius: 4px;
  color: #1976d2;
}

/* 分组搜索框 */
.group-search {
  margin-bottom: 15px;
}

.search-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* 分组列表 */
.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px 0;
}

/* 分组项 */
.group-item {
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.group-item:hover {
  border-color: #2196F3;
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.2);
}

.group-item.active {
  border-color: #4CAF50;
  background-color: #e8f5e9;
  box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
}

/* 分组头部 */
.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.group-name {
  font-weight: 600;
  color: #333;
  font-size: 16px;
}

.group-active-indicator {
  color: #4CAF50;
  font-weight: bold;
  font-size: 18px;
}

/* 分组详情 */
.group-details {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.group-id {
  background-color: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
}

.group-variable-count {
  background-color: #e3f2fd;
  padding: 2px 6px;
  border-radius: 3px;
  color: #1976d2;
}

/* 分组描述 */
.group-description {
  font-size: 13px;
  color: #777;
  line-height: 1.4;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed #eee;
}

/* 无分组提示 */
.no-groups-message {
  text-align: center;
  padding: 30px;
  color: #777;
}

.no-groups-message p {
  margin-bottom: 15px;
  font-size: 16px;
}

/* 当前选中分组详情 */
.active-group-details {
  background-color: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 20px;
}

.active-group-details h3 {
  margin-top: 0;
  color: #2e7d32;
  border-bottom: 1px solid #c8e6c9;
  padding-bottom: 10px;
}

.group-info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.info-tag {
  background-color: #c8e6c9;
  color: #2e7d32;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.info-tag strong {
  margin-right: 5px;
}

/* 变量表格 */
.variables-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.variables-table th {
  background-color: #4CAF50;
  color: white;
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
}

.variables-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
}

.variables-table tr:hover {
  background-color: #f5f5f5;
}

.variables-table tr:last-child td {
  border-bottom: none;
}

.variables-table input[type="text"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.variables-table input[type="text"]:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* 三态选择框 */
.tri-state-select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
}

.tri-state-select:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* 读取值显示 */
.variables-table td .read-value {
  display: inline-block;
  min-width: 80px;
  padding: 4px 8px;
  background-color: #f0f8ff;
  border: 1px solid #d0e0f0;
  border-radius: 4px;
  font-weight: 500;
  color: #2c5aa0;
  text-align: center;
}

.variables-table td .read-value.undefined {
  color: #999;
  font-style: italic;
}

/* 确保分组面板也使用相同的样式 */
.group-variables .variables-table td .read-value {
  display: inline-block;
  min-width: 80px;
  padding: 4px 8px;
  background-color: #f0f8ff;
  border: 1px solid #d0e0f0;
  border-radius: 4px;
  font-weight: 500;
  color: #2c5aa0;
  text-align: center;
}

.group-variables .variables-table td .read-value.undefined {
  color: #999;
  font-style: italic;
}

/* 添加变量按钮 */
.add-variable-btn {
  padding: 10px 20px;
  background-color: #FF9800;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 16px;
  transition: background-color 0.3s;
}

.add-variable-btn:hover {
  background-color: #F57C00;
}

/* 操作按钮区域 */
.plc-actions {
  display: flex;
  gap: 15px;
  margin-top: 20px;
  padding: 20px;
  background-color: #f5f5f5;
  border-radius: 8px;
}

.plc-actions button {
  flex: 1;
  padding: 15px;
  border: none;
  border-radius: 4px;
  background-color: #4CAF50;
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  transition: background-color 0.3s;
}

.plc-actions button:hover:not(:disabled) {
  background-color: #388E3C;
}

.plc-actions button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.plc-actions button:nth-child(2) {
  background-color: #FF9800;
}

.plc-actions button:nth-child(2):hover:not(:disabled) {
  background-color: #F57C00;
}

/* 地址输入框样式 */
.address-input {
  min-width: 120px;
  font-family: 'Courier New', monospace;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .plc-panel {
    padding: 15px;
  }
  
  .plc-controls {
    flex-direction: column;
  }
  
  .plc-controls button {
    width: 100%;
  }
  
  .group-list {
    grid-template-columns: 1fr;
  }
  
  .variables-table {
    font-size: 14px;
  }
  
  .variables-table th,
  .variables-table td {
    padding: 8px 10px;
  }
  
  .plc-actions {
    flex-direction: column;
  }
  
  .plc-actions button {
    width: 100%;
  }
  
  .group-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}